/*****************************************************************************
 * $LastChangedDate: 2009-11-22 22:39:11 -0500 (Sun, 22 Nov 2009) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Simulated time.
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#define GLUE_SIM_TIME_CC 1
#include "base/module.hh"
using namespace base;
#include "math/module.hh"
#include "math/funcs.hh"
using namespace math;
#include "glue/module.hh"
#include "glue/sim_time.hh"

namespace glue {

////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////  SimTime  ////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

SimTime* SimTime::msInstance;

/*****************************************************************************
 * ctor/dtor.
 *****************************************************************************/
SimTime::SimTime( void )
:   mHour(glue::defs::DEFAULT_HOUR)
{
    // NOP
}

SimTime::~SimTime()
{
    // NOP
}

/*****************************************************************************
 * Change hour.
 *****************************************************************************/
void
SimTime::SetHour( const Hour hour )
{
ASSERT_HOUR(hour);
    mHour = hour;
}

/*****************************************************************************
 * Hour methods.
 *****************************************************************************/
bool SimTime::IfDayTime( void                ) const { return IfDayTime( mHour ); }
bool SimTime::IfDayTime( const Hour hour     )       { return (hour > 7) and (hour < 6+12); }
bool SimTime::IfMorningTime( void            ) const { return IfMorningTime( mHour ); }
bool SimTime::IfMorningTime( const Hour hour )       { return (hour >= 6) and (hour <= 7); }
bool SimTime::IfEveningTime( void            ) const { return IfEveningTime( mHour ); }
bool SimTime::IfEveningTime( const Hour hour )       { return (hour >= 6+12) and (hour <= 7+12); }
bool SimTime::IfNightTime( void              ) const { return IfNightTime( mHour ); }
bool SimTime::IfNightTime( const Hour hour   )       { return (hour < 6) or (hour > 7+12); }  // OR (either segment of time)

} // namespace glue
